VERSION_FILE=version.txt

# 设置版本
function setVersion() {
    # 校验版本号是否合规
    if [[ ! $1 =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
        echo "[ERROR] Version $1 is invalid"
        exit 1
    fi
    echo "$1" > $VERSION_FILE
    echo "[SUCCESS] Version is set to $1"
}


# 没传入参数时，输出当前版本号
if [ $# -eq 0 ]; then
    echo "[INFO] Current version is $(cat $VERSION_FILE)"
    exit 1
fi

setVersion $1
